package com.zwjstudy.cachestudy.springcache.redis.controller;

import com.zwjstudy.cachestudy.springcache.redis.entity.User;
import com.zwjstudy.cachestudy.springcache.redis.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * ClassName: CacheController
 * Package: com.zwjstudy.cachestudy.springcache.caffeine.controller
 * Description:
 *
 * @Author: 张文俊
 * @Create: 2025-09-19 - 19:42
 * @Version: v1.0
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("save")
    public User save(@RequestBody User user){
        //存储user

        return userService.save(user);
    }

    @PostMapping("update")
    public void udate(@RequestBody User user){

        userService.update(user);

    }

    @PostMapping("delete")
    public void deleteById(Long id){

        userService.deleteById(id);

    }

    @PostMapping("deleteAll")
    public void deleteAll(){

        userService.deleteAll();

    }

    @GetMapping("getById")
    public User getById(Long id){

        return userService.getById(id);
    }

}
